C:\Program Files\Microsoft Visual Studio 9.0\VC>sqlmetal /server:epruryaw0002 /d
atabase:monitoring /sprocs /code:"c:\temp\dliinq\test.cs"

USE [Monitoring]
GO

/****** Object:  StoredProcedure [proc_EntityLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_EntityLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name],
		[Description],
		[TeamID],
		[Photo],
		[EntityTypeID]
	FROM [Entity]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityLoadAll];
GO

CREATE PROCEDURE [proc_EntityLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name],
		[Description],
		[TeamID],
		[Photo],
		[EntityTypeID]
	FROM [Entity]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityUpdate];
GO

CREATE PROCEDURE [proc_EntityUpdate]
(
	@ID int,
	@Name nvarchar(50),
	@Description nvarchar(250) = NULL,
	@TeamID int,
	@Photo image = NULL,
	@EntityTypeID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Entity]
	SET
		[Name] = @Name,
		[Description] = @Description,
		[TeamID] = @TeamID,
		[Photo] = @Photo,
		[EntityTypeID] = @EntityTypeID
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_EntityInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityInsert];
GO

CREATE PROCEDURE [proc_EntityInsert]
(
	@ID int = NULL output,
	@Name nvarchar(50),
	@Description nvarchar(250) = NULL,
	@TeamID int,
	@Photo image = NULL,
	@EntityTypeID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Entity]
	(
		[Name],
		[Description],
		[TeamID],
		[Photo],
		[EntityTypeID]
	)
	VALUES
	(
		@Name,
		@Description,
		@TeamID,
		@Photo,
		@EntityTypeID
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityDelete];
GO

CREATE PROCEDURE [proc_EntityDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Entity]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_EntityAttributeLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[EntityID],
		[EntityAttributeTypeID],
		[Value]
	FROM [EntityAttribute]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeLoadAll];
GO

CREATE PROCEDURE [proc_EntityAttributeLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[EntityID],
		[EntityAttributeTypeID],
		[Value]
	FROM [EntityAttribute]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeUpdate];
GO

CREATE PROCEDURE [proc_EntityAttributeUpdate]
(
	@ID int,
	@EntityID int,
	@EntityAttributeTypeID int,
	@Value nvarchar(250)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [EntityAttribute]
	SET
		[EntityID] = @EntityID,
		[EntityAttributeTypeID] = @EntityAttributeTypeID,
		[Value] = @Value
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_EntityAttributeInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeInsert];
GO

CREATE PROCEDURE [proc_EntityAttributeInsert]
(
	@ID int = NULL output,
	@EntityID int,
	@EntityAttributeTypeID int,
	@Value nvarchar(250)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [EntityAttribute]
	(
		[EntityID],
		[EntityAttributeTypeID],
		[Value]
	)
	VALUES
	(
		@EntityID,
		@EntityAttributeTypeID,
		@Value
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeDelete];
GO

CREATE PROCEDURE [proc_EntityAttributeDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [EntityAttribute]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeTypeLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeTypeLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeTypeLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_EntityAttributeTypeLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[EntityTypeID],
		[Name]
	FROM [EntityAttributeType]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeTypeLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeTypeLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeTypeLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeTypeLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeTypeLoadAll];
GO

CREATE PROCEDURE [proc_EntityAttributeTypeLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[EntityTypeID],
		[Name]
	FROM [EntityAttributeType]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeTypeLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeTypeLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeTypeUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeTypeUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeTypeUpdate];
GO

CREATE PROCEDURE [proc_EntityAttributeTypeUpdate]
(
	@ID int,
	@EntityTypeID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [EntityAttributeType]
	SET
		[EntityTypeID] = @EntityTypeID,
		[Name] = @Name
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeTypeUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeTypeUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_EntityAttributeTypeInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeTypeInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeTypeInsert];
GO

CREATE PROCEDURE [proc_EntityAttributeTypeInsert]
(
	@ID int,
	@EntityTypeID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [EntityAttributeType]
	(
		[ID],
		[EntityTypeID],
		[Name]
	)
	VALUES
	(
		@ID,
		@EntityTypeID,
		@Name
	)

	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeTypeInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeTypeInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityAttributeTypeDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityAttributeTypeDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityAttributeTypeDelete];
GO

CREATE PROCEDURE [proc_EntityAttributeTypeDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [EntityAttributeType]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityAttributeTypeDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityAttributeTypeDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityTypeLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityTypeLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityTypeLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_EntityTypeLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name]
	FROM [EntityType]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityTypeLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityTypeLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityTypeLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityTypeLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityTypeLoadAll];
GO

CREATE PROCEDURE [proc_EntityTypeLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name]
	FROM [EntityType]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityTypeLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityTypeLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityTypeUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityTypeUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityTypeUpdate];
GO

CREATE PROCEDURE [proc_EntityTypeUpdate]
(
	@ID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [EntityType]
	SET
		[Name] = @Name
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityTypeUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityTypeUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_EntityTypeInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityTypeInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityTypeInsert];
GO

CREATE PROCEDURE [proc_EntityTypeInsert]
(
	@ID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [EntityType]
	(
		[ID],
		[Name]
	)
	VALUES
	(
		@ID,
		@Name
	)

	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityTypeInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityTypeInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_EntityTypeDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_EntityTypeDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_EntityTypeDelete];
GO

CREATE PROCEDURE [proc_EntityTypeDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [EntityType]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_EntityTypeDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_EntityTypeDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_GameLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[TeamID],
		[Name],
		[Description],
		[CreationDate]
	FROM [Game]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameLoadAll];
GO

CREATE PROCEDURE [proc_GameLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[TeamID],
		[Name],
		[Description],
		[CreationDate]
	FROM [Game]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameUpdate];
GO

CREATE PROCEDURE [proc_GameUpdate]
(
	@ID int,
	@TeamID int,
	@Name nvarchar(50),
	@Description nvarchar(250) = NULL,
	@CreationDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Game]
	SET
		[TeamID] = @TeamID,
		[Name] = @Name,
		[Description] = @Description,
		[CreationDate] = @CreationDate
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_GameInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameInsert];
GO

CREATE PROCEDURE [proc_GameInsert]
(
	@ID int = NULL output,
	@TeamID int,
	@Name nvarchar(50),
	@Description nvarchar(250) = NULL,
	@CreationDate datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Game]
	(
		[TeamID],
		[Name],
		[Description],
		[CreationDate]
	)
	VALUES
	(
		@TeamID,
		@Name,
		@Description,
		@CreationDate
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameDelete];
GO

CREATE PROCEDURE [proc_GameDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Game]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameEntityLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameEntityLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameEntityLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_GameEntityLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[GameID],
		[EntityID],
		[ParentGameEntityID],
		[GameRoleID],
		[Visible]
	FROM [GameEntity]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameEntityLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameEntityLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameEntityLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameEntityLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameEntityLoadAll];
GO

CREATE PROCEDURE [proc_GameEntityLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[GameID],
		[EntityID],
		[ParentGameEntityID],
		[GameRoleID],
		[Visible]
	FROM [GameEntity]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameEntityLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameEntityLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameEntityUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameEntityUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameEntityUpdate];
GO

CREATE PROCEDURE [proc_GameEntityUpdate]
(
	@ID int,
	@GameID int,
	@EntityID int,
	@ParentGameEntityID int = NULL,
	@GameRoleID int,
	@Visible bit
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [GameEntity]
	SET
		[GameID] = @GameID,
		[EntityID] = @EntityID,
		[ParentGameEntityID] = @ParentGameEntityID,
		[GameRoleID] = @GameRoleID,
		[Visible] = @Visible
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameEntityUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameEntityUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_GameEntityInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameEntityInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameEntityInsert];
GO

CREATE PROCEDURE [proc_GameEntityInsert]
(
	@ID int = NULL output,
	@GameID int,
	@EntityID int,
	@ParentGameEntityID int = NULL,
	@GameRoleID int,
	@Visible bit
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [GameEntity]
	(
		[GameID],
		[EntityID],
		[ParentGameEntityID],
		[GameRoleID],
		[Visible]
	)
	VALUES
	(
		@GameID,
		@EntityID,
		@ParentGameEntityID,
		@GameRoleID,
		@Visible
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameEntityInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameEntityInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameEntityDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameEntityDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameEntityDelete];
GO

CREATE PROCEDURE [proc_GameEntityDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [GameEntity]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameEntityDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameEntityDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameRoleLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameRoleLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameRoleLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_GameRoleLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name]
	FROM [GameRole]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameRoleLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameRoleLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameRoleLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameRoleLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameRoleLoadAll];
GO

CREATE PROCEDURE [proc_GameRoleLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name]
	FROM [GameRole]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameRoleLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameRoleLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameRoleUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameRoleUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameRoleUpdate];
GO

CREATE PROCEDURE [proc_GameRoleUpdate]
(
	@ID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [GameRole]
	SET
		[Name] = @Name
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameRoleUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameRoleUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_GameRoleInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameRoleInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameRoleInsert];
GO

CREATE PROCEDURE [proc_GameRoleInsert]
(
	@ID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [GameRole]
	(
		[ID],
		[Name]
	)
	VALUES
	(
		@ID,
		@Name
	)

	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameRoleInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameRoleInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GameRoleDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GameRoleDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GameRoleDelete];
GO

CREATE PROCEDURE [proc_GameRoleDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [GameRole]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GameRoleDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_GameRoleDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GPSPointLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GPSPointLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GPSPointLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_GPSPointLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[EntityName],
		[GameName],
		[Login],
		[Password],
		[Latitude],
		[Longitude],
		[Time],
		[Speed],
		[Altitude],
		[GameEntityID],
		[UserID]
	FROM [GPSPoint]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GPSPointLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_GPSPointLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GPSPointLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GPSPointLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GPSPointLoadAll];
GO

CREATE PROCEDURE [proc_GPSPointLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[EntityName],
		[GameName],
		[Login],
		[Password],
		[Latitude],
		[Longitude],
		[Time],
		[Speed],
		[Altitude],
		[GameEntityID],
		[UserID]
	FROM [GPSPoint]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GPSPointLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_GPSPointLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GPSPointUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GPSPointUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GPSPointUpdate];
GO

CREATE PROCEDURE [proc_GPSPointUpdate]
(
	@ID int,
	@EntityName nvarchar(50),
	@GameName nvarchar(50) = NULL,
	@Login nvarchar(50) = NULL,
	@Password nvarchar(50) = NULL,
	@Latitude float,
	@Longitude float,
	@Time datetime,
	@Speed float = NULL,
	@Altitude float = NULL,
	@GameEntityID int = NULL,
	@UserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [GPSPoint]
	SET
		[EntityName] = @EntityName,
		[GameName] = @GameName,
		[Login] = @Login,
		[Password] = @Password,
		[Latitude] = @Latitude,
		[Longitude] = @Longitude,
		[Time] = @Time,
		[Speed] = @Speed,
		[Altitude] = @Altitude,
		[GameEntityID] = @GameEntityID,
		[UserID] = @UserID
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GPSPointUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_GPSPointUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_GPSPointInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GPSPointInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GPSPointInsert];
GO

CREATE PROCEDURE [proc_GPSPointInsert]
(
	@ID int = NULL output,
	@EntityName nvarchar(50),
	@GameName nvarchar(50) = NULL,
	@Login nvarchar(50) = NULL,
	@Password nvarchar(50) = NULL,
	@Latitude float,
	@Longitude float,
	@Time datetime,
	@Speed float = NULL,
	@Altitude float = NULL,
	@GameEntityID int = NULL,
	@UserID int = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [GPSPoint]
	(
		[EntityName],
		[GameName],
		[Login],
		[Password],
		[Latitude],
		[Longitude],
		[Time],
		[Speed],
		[Altitude],
		[GameEntityID],
		[UserID]
	)
	VALUES
	(
		@EntityName,
		@GameName,
		@Login,
		@Password,
		@Latitude,
		@Longitude,
		@Time,
		@Speed,
		@Altitude,
		@GameEntityID,
		@UserID
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GPSPointInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_GPSPointInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_GPSPointDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_GPSPointDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_GPSPointDelete];
GO

CREATE PROCEDURE [proc_GPSPointDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [GPSPoint]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_GPSPointDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_GPSPointDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_MarkerHashLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_MarkerHashLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_MarkerHashLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_MarkerHashLoadByPrimaryKey]
(
	@Hash datetime
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[Hash],
		[MarkerName],
		[GameName],
		[Login]
	FROM [MarkerHash]
	WHERE
		([Hash] = @Hash)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_MarkerHashLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_MarkerHashLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_MarkerHashLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_MarkerHashLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_MarkerHashLoadAll];
GO

CREATE PROCEDURE [proc_MarkerHashLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[Hash],
		[MarkerName],
		[GameName],
		[Login]
	FROM [MarkerHash]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_MarkerHashLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_MarkerHashLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_MarkerHashUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_MarkerHashUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_MarkerHashUpdate];
GO

CREATE PROCEDURE [proc_MarkerHashUpdate]
(
	@Hash datetime,
	@MarkerName nvarchar(50),
	@GameName nvarchar(50) = NULL,
	@Login nvarchar(50) = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [MarkerHash]
	SET
		[MarkerName] = @MarkerName,
		[GameName] = @GameName,
		[Login] = @Login
	WHERE
		[Hash] = @Hash


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_MarkerHashUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_MarkerHashUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_MarkerHashInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_MarkerHashInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_MarkerHashInsert];
GO

CREATE PROCEDURE [proc_MarkerHashInsert]
(
	@Hash datetime,
	@MarkerName nvarchar(50),
	@GameName nvarchar(50) = NULL,
	@Login nvarchar(50) = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [MarkerHash]
	(
		[Hash],
		[MarkerName],
		[GameName],
		[Login]
	)
	VALUES
	(
		@Hash,
		@MarkerName,
		@GameName,
		@Login
	)

	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_MarkerHashInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_MarkerHashInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_MarkerHashDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_MarkerHashDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_MarkerHashDelete];
GO

CREATE PROCEDURE [proc_MarkerHashDelete]
(
	@Hash datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [MarkerHash]
	WHERE
		[Hash] = @Hash
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_MarkerHashDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_MarkerHashDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_TeamLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_TeamLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_TeamLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_TeamLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name],
		[Description]
	FROM [Team]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_TeamLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_TeamLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_TeamLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_TeamLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_TeamLoadAll];
GO

CREATE PROCEDURE [proc_TeamLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name],
		[Description]
	FROM [Team]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_TeamLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_TeamLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_TeamUpdate]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_TeamUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_TeamUpdate];
GO

CREATE PROCEDURE [proc_TeamUpdate]
(
	@ID int,
	@Name nvarchar(50),
	@Description nvarchar(250) = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [Team]
	SET
		[Name] = @Name,
		[Description] = @Description
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_TeamUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_TeamUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_TeamInsert]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_TeamInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_TeamInsert];
GO

CREATE PROCEDURE [proc_TeamInsert]
(
	@ID int = NULL output,
	@Name nvarchar(50),
	@Description nvarchar(250) = NULL
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [Team]
	(
		[Name],
		[Description]
	)
	VALUES
	(
		@Name,
		@Description
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_TeamInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_TeamInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_TeamDelete]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_TeamDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_TeamDelete];
GO

CREATE PROCEDURE [proc_TeamDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [Team]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_TeamDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_TeamDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_UserLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Login],
		[Password],
		[TeamID]
	FROM [User]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserLoadAll]    Script Date: 16.01.2008 14:32:39 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserLoadAll];
GO

CREATE PROCEDURE [proc_UserLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Login],
		[Password],
		[TeamID]
	FROM [User]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserUpdate]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserUpdate];
GO

CREATE PROCEDURE [proc_UserUpdate]
(
	@ID int,
	@Login nvarchar(50),
	@Password nvarchar(50),
	@TeamID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [User]
	SET
		[Login] = @Login,
		[Password] = @Password,
		[TeamID] = @TeamID
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_UserInsert]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserInsert];
GO

CREATE PROCEDURE [proc_UserInsert]
(
	@ID int = NULL output,
	@Login nvarchar(50),
	@Password nvarchar(50),
	@TeamID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [User]
	(
		[Login],
		[Password],
		[TeamID]
	)
	VALUES
	(
		@Login,
		@Password,
		@TeamID
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserDelete]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserDelete];
GO

CREATE PROCEDURE [proc_UserDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [User]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserRoleLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserRoleLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserRoleLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_UserRoleLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name]
	FROM [UserRole]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserRoleLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserRoleLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserRoleLoadAll]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserRoleLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserRoleLoadAll];
GO

CREATE PROCEDURE [proc_UserRoleLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[Name]
	FROM [UserRole]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserRoleLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserRoleLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserRoleUpdate]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserRoleUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserRoleUpdate];
GO

CREATE PROCEDURE [proc_UserRoleUpdate]
(
	@ID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [UserRole]
	SET
		[Name] = @Name
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserRoleUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserRoleUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_UserRoleInsert]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserRoleInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserRoleInsert];
GO

CREATE PROCEDURE [proc_UserRoleInsert]
(
	@ID int,
	@Name nvarchar(50)
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [UserRole]
	(
		[ID],
		[Name]
	)
	VALUES
	(
		@ID,
		@Name
	)

	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserRoleInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserRoleInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserRoleDelete]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserRoleDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserRoleDelete];
GO

CREATE PROCEDURE [proc_UserRoleDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [UserRole]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserRoleDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserRoleDelete Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserToRoleLoadByPrimaryKey]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserToRoleLoadByPrimaryKey]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserToRoleLoadByPrimaryKey];
GO

CREATE PROCEDURE [proc_UserToRoleLoadByPrimaryKey]
(
	@ID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[UserID],
		[UserRoleID]
	FROM [UserToRole]
	WHERE
		([ID] = @ID)

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserToRoleLoadByPrimaryKey Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserToRoleLoadByPrimaryKey Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserToRoleLoadAll]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserToRoleLoadAll]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserToRoleLoadAll];
GO

CREATE PROCEDURE [proc_UserToRoleLoadAll]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[ID],
		[UserID],
		[UserRoleID]
	FROM [UserToRole]

	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserToRoleLoadAll Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserToRoleLoadAll Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserToRoleUpdate]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserToRoleUpdate]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserToRoleUpdate];
GO

CREATE PROCEDURE [proc_UserToRoleUpdate]
(
	@ID int,
	@UserID int,
	@UserRoleID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [UserToRole]
	SET
		[UserID] = @UserID,
		[UserRoleID] = @UserRoleID
	WHERE
		[ID] = @ID


	SET @Err = @@Error


	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserToRoleUpdate Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserToRoleUpdate Error on Creation'
GO




/****** Object:  StoredProcedure [proc_UserToRoleInsert]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserToRoleInsert]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserToRoleInsert];
GO

CREATE PROCEDURE [proc_UserToRoleInsert]
(
	@ID int = NULL output,
	@UserID int,
	@UserRoleID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [UserToRole]
	(
		[UserID],
		[UserRoleID]
	)
	VALUES
	(
		@UserID,
		@UserRoleID
	)

	SET @Err = @@Error

	SELECT @ID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserToRoleInsert Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserToRoleInsert Error on Creation'
GO

/****** Object:  StoredProcedure [proc_UserToRoleDelete]    Script Date: 16.01.2008 14:32:40 ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[proc_UserToRoleDelete]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [proc_UserToRoleDelete];
GO

CREATE PROCEDURE [proc_UserToRoleDelete]
(
	@ID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [UserToRole]
	WHERE
		[ID] = @ID
	SET @Err = @@Error

	RETURN @Err
END
GO


-- Display the status of Proc creation
IF (@@Error = 0) PRINT 'Procedure Creation: proc_UserToRoleDelete Succeeded'
ELSE PRINT 'Procedure Creation: proc_UserToRoleDelete Error on Creation'
GO
